package scala.day03

import scala.io.Source

object Demo09Implicit {
  def main(args: Array[String]): Unit = {
    /**
      * 隐式转化参数
      */
    def fun(str:String):String => Unit = {

      def f (per :String): Unit ={
        println(str+"\t"+per)
      }
      f
    }
    fun("java")("后缀")
    //简写
    def fun1(str:String)(per:String): Unit ={
      println(str+"\t"+per)
    }
    fun1("scala")("后缀")

    /**
      * 隐式转化参数
      *
      * 方法调用的简写
      */
    def fun2(str:String)(implicit per:String): Unit ={
      println(str+"\t"+per)
    }

    //隐式转化变量
    implicit val str: String = "默认值"
    fun2("spark")
    fun2("scala")
    //应用场景
    Source.fromFile("data/word.txt")
  }
}
